package cn.edu.sjtu.se.dslab.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.sjtu.se.dslab.component.data.EquipmentCategory;
import cn.edu.sjtu.se.dslab.dao.IEquipmentCategoryDao;
import cn.edu.sjtu.se.dslab.service.IEquipmentCategoryService;

@Service("equipmentCategoryService")
@Transactional
public class EquipmentCategoryServiceImpl implements IEquipmentCategoryService {

	@Resource(name="equipmentCategoryDao")
	IEquipmentCategoryDao equipmentCategoryDao;
	
	@Override
	public boolean addEquipmentCategory(EquipmentCategory equipmentCategory) {
		// TODO Auto-generated method stub
		equipmentCategoryDao.save(equipmentCategory);
		return true;
	}

	@Override
	public boolean updateEquipmentCategory(EquipmentCategory equipmentCategory) {
		// TODO Auto-generated method stub
		equipmentCategoryDao.update(equipmentCategory);
		return true;
	}

	@Override
	public List<EquipmentCategory> getAllEquipmentCategoryList() {
		// TODO Auto-generated method stub
		return equipmentCategoryDao.queryAll();
	}

	@Override
	public EquipmentCategory getEquipmentCategoryById(long id) {
		// TODO Auto-generated method stub
		return equipmentCategoryDao.queryById(id);
	}

	@Override
	public EquipmentCategory getEquipmentCategoryByType(String type) {
		// TODO Auto-generated method stub
		return equipmentCategoryDao.queryByType(type);
	}

	@Override
	public boolean deleteEquipmentCategory(EquipmentCategory equipmentCategory) {
		// TODO Auto-generated method stub
		if (equipmentCategory != null) {
			equipmentCategory.setDeleted(true);
			equipmentCategoryDao.update(equipmentCategory);
		}
		return true;
	}

}
